import urllib.request

url='https://fanyi.baidu.com/v2transapi?from=en&to=zh'

# 注意使用正则表达式转换时的匹配错误
headers = {
    'Accept': ' */*',
    # 'Accept-Encoding': ' gzip, deflate, br',
    'Accept-Language': ' zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7',
    'Acs-Token': ' 1662966193448_1662973256369_BJBKkvjVqRogO5suBfevlPeC3hMTIllMckLLYKi+MKvN0SC/CIeuOWsYwOE6Cqs6/MFSvFqjjfQJV0fLdWEOkYYN42+EGqG1HyocX3Pcb613mfJp3GwRfqhim5B/IqQFIFx6xMpA9w+EcNyV3mQjCDZXheisCFGhSa/IKkfdx/HDrriBmmKR678nu0O9pJxSDr2NqflGCXs734GLzCiQ+mwhW82WRLK9MUrpUku1aQJnzZLaMYmvhI1KKI/KYARafS6Z/0vavCeIC5449uMJq6CUc8W7NaUloyF/JEOIEG6PyMwuou/cS3sA5B0Y0FkxYDhAxgFWyLdlt9ZCqJqx6Q==',
    'Connection': ' keep-alive',
    'Content-Length': ' 117',
    'Content-Type': ' application/x-www-form-urlencoded; charset=UTF-8',
    'Cookie': 'BIDUPSID=B071603F5E5A38ADFA9013E346563913; PSTM=1614410995; BAIDUID=9410E19143D89D0B606DAC96973E6B1E:FG=1; REALTIME_TRANS_SWITCH=1; FANYI_WORD_SWITCH=1; HISTORY_SWITCH=1; SOUND_SPD_SWITCH=1; SOUND_PREFER_SWITCH=1; APPGUIDE_10_0_2=1; BDUSS=1o3cmdYMUg3ZHpxREplWENrdHhBWC1CTExqUHZSVkQtQnhOeTluNEVudjFnUFJpRVFBQUFBJCQAAAAAAAAAAAEAAABCnFJYSUtBUk9TvfDEvtHQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAPXzzGL188xib; BDUSS_BFESS=1o3cmdYMUg3ZHpxREplWENrdHhBWC1CTExqUHZSVkQtQnhOeTluNEVudjFnUFJpRVFBQUFBJCQAAAAAAAAAAAEA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T7johRTWqR4ePoaLxonDh83Bn_L2xQJHmLOBt3O5hvvhb6O3M7-qfKmDloOW-TB5bbPLUQF5l8-sq0x0bOte-bQXH_E5bj2qRAj_Dty3e; delPer=0; PSINO=2; BA_HECTOR=0l0h20810h2ha08ga584ukn01hht59819; ZFY=oYmfI4F1:BzHHs:BOd:BEE:Bzj:AGBG3AEtXoXaSoOIWDUBMC; ZD_ENTRY=baidu; H_PS_PSSID=37146_36542_36463_37117_36885_36786_37261_26350_37233; ab_sr=1.0.1_NzIyMjdmNTM2Y2U3MjM4OTRmNjZjZDNhMjNlYTQ5MjczYjIyYWNhM2IxYWJlODdiYWRmMzAxYjdhYmMxNjEwODMwOWE5ZmY0MmFiNTdlZTQ2MTNiZTA3NmIxNTg0MDkzYzgwOGY4NmNiYTQ3MjRiNTExMTA1Zjg0MGQxNDgxMWVlYmE5YzY2MzY4NTljYTU4YTkyNDM4MjkxNDJiNzBiOTlkMzYzZDk1ZDhjZTBlY2NkNTE3MWQ3YmFhZThlZTY4; Hm_lpvt_64ecd82404c51e03dc91cb9e8c025574=1662973256',
    'Host': ' fanyi.baidu.com',
    'Origin': 'https://fanyi.baidu.com',
    'Referer': 'https://fanyi.baidu.com/?aldtype=16047',
    'sec-ch-ua': ' "Google Chrome";v="105", "Not)A;Brand";v="8", "Chromium";v="105"',
    'sec-ch-ua-mobile': ' ?0',
    'sec-ch-ua-platform': ' "Windows"',
    'Sec-Fetch-Dest': ' empty',
    'Sec-Fetch-Mode': ' cors',
    'Sec-Fetch-Site': ' same-origin',
    'User-Agent': ' Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36',
    'X-Requested-With': ' XMLHttpRequest'
}

data = {
'from': 'en',
'to': 'zh',
'query': 'spider',
'simple_means_flag': '3',
'sign': '63766.268839',
'token': '00ed7e1cf4396b84a660f8c040daf40f',
'domain': 'common'
}

# post请求方式的参数 必须进行编码 并且要调用encode方法
data = urllib.parse.urlencode(data).encode('utf-8')

# 请求对象的定制
request = urllib.request.Request(url=url,data=data,headers=headers)

# 模拟浏览器向服务器发送请求
response = urllib.request.urlopen(request)

# 获取响应的数据
content = response.read().decode('utf-8')

import  json
obj = json.loads(content)
print(obj)